package com.holly.unit.core.enums;

import cn.hutool.core.util.ObjectUtil;

/**
 * 类描述: Query 规则 常量
 *
 * @author fxr
 * @version 1.0.0
 * @date 2022/4/6 10:31
 */
public enum AndOrEnum {

    AND("&&","and","并且"),
    OR("||","or","或者");

    private String value;

    private String condition;

    private String msg;

    AndOrEnum(String value, String condition, String msg){
        this.value = value;
        this.condition = condition;
        this.msg = msg;
    }

    public String getValue() {
        return value;
    }

    public void setValue(String value) {
        this.value = value;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public String getCondition() {
        return condition;
    }

    public void setCondition(String condition) {
        this.condition = condition;
    }

    public static AndOrEnum getByValue(String value){
        if(ObjectUtil.isEmpty(value)) {
            return null;
        }
        for(AndOrEnum val :values()){
            if (val.getValue().equals(value) || val.getCondition().equals(value)){
                return val;
            }
        }
        return  null;
    }

}
